﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuisnessLayer1
{
    public class KlantService : IKlantService
    {
        public IEnumerable<Klanten> GetAlleKlanten()
        {
            List<Klanten>  KlantenLijst = new List<Klanten>();
            SqlConnection myConn = null;
            Klanten alle = new Klanten();
            try
            {
                using (myConn = new SqlConnection(BPcars.GetConnection()))
                {
                    myConn.Open();

                    var cmd = new SqlCommand("Select * from Klanten", myConn);
                    var reader = cmd.ExecuteReader();



                    while (reader.Read())
                    {
                        int klantnr = Convert.ToInt32(reader["klantnr"]);
                        string naam = Convert.ToString(reader["naam"]);
                        string voornaam = Convert.ToString(reader["voornaam"]);
                        string adres = Convert.ToString(reader["adres"]);
                        string postcode = Convert.ToString(reader["postcode"]);
                        string telefoon = Convert.ToString(reader["telefoon"]);
                        string email = Convert.ToString(reader["email"]);
                        float getrouwheidsKm = (float)reader["getrouwheidsKm"];



                    }

                    reader.Close();
                    cmd.Dispose();




                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return KlantenLijst;
        }
    }
}
